![]() |
PATH![]() |
![]() ![]() |
Before reading this section, you should be familiar with the information provided in Run Handlers.
The declaration of a variable or property identifier is the first valid occurrence of the identifier in a script. The form and location of the declaration determine how AppleScript treats the identifier in that script.
The scope of a variable or property declaration is the range over which AppleScript recognizes the declared identifier within a script. The scope of a property declaration is the entire script or script object in which it is defined.
It is often convenient to limit the scope of a particular identifier to a single handler--that is, to treat the identifier as a local variable within a handler. After a local variable has served its purpose, its identifier no longer has any value associated with it and can be used again for other purposes elsewhere in the script.
If you want the value of a script variable to persist after a script is run, or if you wish to use the same identifier in several different places in a script, you can declare it as either a script property or a global variable. AppleScript keeps track of properties and global variables across multiple handlers and script objects within a single script.
The following sections provide additional information about the scope of AppleScript variables and properties: